﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DinhMuc.Public;


namespace DinhMuc.DAL
{
    public class tblKhachHangDAL
    {
        clsConnect cn = new clsConnect();
        public DataTable bangKhachHang()
        {
            return cn.LoadTableStore("sp_khachhang_select");
        }
        public void import(string sql, tblKhachHangPublic p)
        {
            int para = 8;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@A";
            name[1] = "@B";
            name[2] = "@C";
            name[3] = "@D";
            name[4] = "@E";
            name[5] = "@F";
            name[6] = "@G";
            name[7] = "@H";
            value[0] = p.maKH;
            value[1] = p.tenCty;
            value[2] = p.diaChi;
            value[3] = p.msThue;
            value[4] = p.tell;
            value[5] = p.email;
            value[6] = p.website;
            value[7] = p.nguoiLienHe;
            cn.UpdateTable(sql, name, value, para);
        }
        public int themKH(tblKhachHangPublic p)
        {
            int para = 8;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@maKH";
            name[1] = "@tenCty";
            name[2] = "@diaChi";
            name[3] = "@msThue";
            name[4] = "@tell";
            name[5] = "@email";
            name[6] = "@website";
            name[7] = "@nguoiLienHe";
            value[0]=p.maKH;
            value[1]=p.tenCty;
            value[2]=p.diaChi;
            value[3]=p.msThue;
            value[4]=p.tell;
            value[5]=p.email;
            value[6]=p.website;
            value[7]=p.nguoiLienHe;
            return cn.UpdateTableStore("sp_khachHang_insert", name, value, para);    
        }
        public int suaKH(tblKhachHangPublic p)
        {
            int para = 8;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@maKH";
            name[1] = "@tenCty";
            name[2] = "@diaChi";
            name[3] = "@msThue";
            name[4] = "@tell";
            name[5] = "@email";
            name[6] = "@website";
            name[7] = "@nguoiLienHe";
            value[0] = p.maKH;
            value[1] = p.tenCty;
            value[2] = p.diaChi;
            value[3] = p.msThue;
            value[4] = p.tell;
            value[5] = p.email;
            value[6] = p.website;
            value[7] = p.nguoiLienHe;
            return cn.UpdateTableStore("sp_khachHang_update", name, value, para);    
        }
        public int xoaKH(string maKH)
        {
            int para = 1;
            string[] name = new string[para];
            object[] value = new object[para];
            name[0] = "@maKH";
            value[0] = maKH;
            return cn.UpdateTableStore("sp_khachHang_delete", name, value, para);
        }
    }
}
